package com.freesky.provider.content.handle;

import com.freesky.common.exception.MyException;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.utils.reponse.JSONResponseDiretor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 异常捕获
 * @author Administrator
 *
 */
@ControllerAdvice
@Slf4j
public class ExceptionAdvice {
	@ResponseBody
	@ExceptionHandler(value= MyException.class)
	public JSONResponse ajaxAuthorizationException(MyException e){
		if (e.getThrowable() != null) {
			log.error("统一异常信息打印{}",e.getThrowable());
		}
		return JSONResponseDiretor.buildMyExceptionJSONResponse(e);
	}
}
